import sys
n=int(sys.stdin.readline())
a1,a2,a3=map(int, sys.stdin.readline().split())
b1,b2,b3=map(int, sys.stdin.readline().split())
win=min(a1,b2)+min(a2,b3)+min(a3,b1)
lose=n-min(a1,b1+b3)-min(a2,b2+b1)-min(a3,b3+b2)
print(lose,win)
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
vector<int> a(3),b(3);
for(int i=0;i<3;i++)cin>>a[i];
for(int i=0;i<3;i++)cin>>b[i];
int mx = 0, mn = 1e9+7;
for(int i=0;i<3;i++)mx+=min(a[i], b[(i+1)%3]);
vector<array<int,2>> bf;
for(int i=0;i<3;i++)
{
bf.push_back({i, i});
bf.push_back({i, (i+2)%3});
}
sort(bf.begin(), bf.end());
do
{
vector<int> ta=a, tb=b;
int tmn=0;
for(int i=0;i<bf.size();i++)
{
int sub = min(ta[bf[i][0]], tb[bf[i][1]]);
ta[bf[i][0]]-=sub;
tb[bf[i][1]]-=sub;
}
for(int i=0;i<3;i++)tmn+=min(ta[i], tb[(i+1)%3]);
mn=min(mn, tmn);
} while (next_permutation(bf.begin(), bf.end()));
cout << mn << ' ' << mx << '\n';
return 0;
}
1301C - Ayoub's function | 38E - Let's Go Rolling |
171G - Mysterious numbers - 2 | 1183C - Computer Game |
400C - Inna and Huge Candy Matrix | 417A - Elimination |
222A - Shooshuns and Sequence | 1736A - Make A Equal to B |
1736B - Playing with GCD | 887C - Solution for Cube |
1737C - Ela and Crickets | 1741C - Minimize the Thickness |
1741A - Compare T-Shirt Sizes | 1741D - Masha and a Beautiful Tree |
109B - Lucky Probability | 1741B - Funny Permutation |
1741E - Sending a Sequence Over the Network | 344B - Simple Molecules |
370A - Rook Bishop and King | 546E - Soldier and Traveling |
1741G - Kirill and Company | 1200B - Block Adventure |
1088B - Ehab and subtraction | 1270B - Interesting Subarray |
478C - Table Decorations | 1304C - Air Conditioner |
1311C - Perform the Combo | 1519C - Berland Regional |
361A - Levko and Table | 5E - Bindian Signalizing |